package com.anzia.demo07;

/**
 *@ClassName BufferAndBuild_Demo
 *@Description
 *@Author Anzia.
 *@Date 2021/4/11 17:36
 *@Version 1.0
 **/
public class StringBuffer_Demo {
    public static void main(String[] args) {
        StringBuffer buffer = new StringBuffer();

        //append() 追加
        buffer.append("Java世界第一");
        System.out.println(buffer.toString());
        buffer.append("Java真香");
        System.out.println(buffer.toString());

        //insert() 添加
        buffer.insert(0, "我在最前面");
        System.out.println(buffer);

        //replace() 替换
        buffer.replace(0,5,"hello");
        System.out.println(buffer);

        //delete() 删除
        buffer.delete(0,5);
        System.out.println(buffer);
    }
}
